home *** CD-ROM | disk | FTP | other *** search
- Path: abcfd20.larc.nasa.gov!amiga-request
- From: amiga-request@abcfd20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
- Subject: v90i258: DKBTrace 2.01 - DKBtrace Ray-Tracer, Part10/10
- Reply-To: David Schanen <mtv@milton.u.washington.edu>
- Newsgroups: comp.sources.amiga
- Message-ID: <comp.sources.amiga:v90i258@abcfd20.larc.nasa.gov>
- References: <comp.sources.amiga:v90i249@abcfd20.larc.nasa.gov>
- Date: 03 Sep 90 23:22:50 GMT
- Approved: tadguy@uunet.UU.NET (Tad Guy)
- X-Mail-Submissions-To: amiga@uunet.uu.net
- X-Post-Discussions-To: comp.sys.amiga
-
- Submitted-by: David Schanen <mtv@milton.u.washington.edu>
- Posting-number: Volume 90, Issue 258
- Archive-name: applications/dkbtrace-2.01/part10
-
- #!/bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 10 (of 10)."
- # Contents: Docs/dkb.doc
- # Wrapped by tadguy@abcfd20 on Mon Sep 3 19:21:23 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'Docs/dkb.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Docs/dkb.doc'\"
- else
- echo shar: Extracting \"'Docs/dkb.doc'\" \(65462 characters\)
- sed "s/^X//" >'Docs/dkb.doc' <<'END_OF_FILE'
- X
- X
- X
- X
- X
- X
- X DKBtrace Ray-Tracer, Amiga/IBM Version 2.0
- X
- X "It's free, and it's well worth the price!"
- X
- X
- X
- X
- X
- X
- X
- X This program was written by:
- X
- X David Buck
- X 22C Sonnet Cres.
- X Nepean, Ontario
- X Canada, K2H 8W7
- X
- X It has been made freely distributable. The author retains the copyright
- X to the program but authorizes free distribution by BBS'es, networks or
- X by magnetic media. The distributer may choose to charge for the cost of
- X the disk but should not sell the software for profit. Non-profit
- X organizations such as clubs may charge for the software so long as the
- X price is reasonable (less than $5.00 more than the cost of the disk) and
- X so long as the buyers are informed that the program is freely
- X distributable.
- X
- X The images and data files generated by the raytracer are the property of
- X the user of the software and may be used for any purpose without
- X restriction.
- X
- X The author makes no guarantees or warantees with this program and claims
- X no responsibility for any damage or loss of time caused by this program.
- X Bug reports may be sent to the author but the author is under no
- X obligation to provide bug fixes, features, or any support for this
- X software.
- X
- X I would also like to place the following conditions on the use of this
- X program:
- X
- X 1) that it should not be used as part of any commercial package without
- X my explicit written consent.
- X
- X 2) if you make any neat and interesting pictures, please send them to
- X me.
- X
- X 3) If you make any changes to the source code, please let me know. I'd
- X like to see what you've done.
- X
- X 4) This text file should accompany the program.
- X
- X
- X
- X I can be reached on the following BBS'es
- X
- X ATX (613) 526-4141
- X OMX (613) 731-3419
- X Mystic (613) 731-0088 or (613) 731-6698
- X FidoNet 1:163/109.9
- X Bitnet David_Buck@Carleton.CA
- X
- X
- X
- X
- XSection 0.1 - Recent Update History:
- X
- X Version 1.2 First release
- X Version 2.0 Conversion to the IBM done by Aaron A. Collins
- X New textures, Specular and Phong highlighting added by
- X Aaron A. Collins
- X Triangle, Smooth Triangle, Sphere, Plane support added by
- X David Buck
- X RAW, IFF and GIF image mapping added by David Buck and Aaron
- X Collins
- X Transparency and Fog added by David Buck
- X GIF format file reader by Steve Bennett (used with permission)
- X New Noise and DNoise functions by Robert Skinner
- X (used with permission)
- X
- X Aaron Collins can be reached on the following BBS'es
- X
- X Lattice BBS (708) 916-1200
- X The Information Exchange BBS (708) 945-5575
- X Stillwaters BBS (708) 403-2826
- X
- X AAC: As of July of 1990, there will be a Ray-Trace specific BBS in the
- X (708) Area Code (Chicago suburbia) for all you Traceaholics out there.
- X The phone number of this new BBS is (708) 358-5611. I will be Co-Sysop
- X of that board. There is also a new Ray-Trace and Computer-Generated
- X Art specific SIG on Compuserve, GO COMART. And now, back to the DOCS...
- X
- X Version 2.0 includes ANSI-C function prototyping for ALL functions,
- X TARGA format output file capability, and a reversal of the order of
- X writing screen data from the original DKB/QRT "RAW" file format. For
- X IBM's, it has a crude VGA 320x200 by 256 color display rendering
- X ability. If the image requested is larger than 320x200, every other
- X pixel horizontally and vertically is dropped from the display to keep it
- X all on the screen.
- X
- X Version 2.0 compiles under Turbo-C 2.0 on the IBM P.C. and Lattice C
- X 5.05 on the Amiga. The only file which contains the ANSI extensions is
- X dkbproto.h, so for non-ANSI compilers, you only need to remove the
- X declaration of the parameters in the config.h file and the whole thing
- X should compile. There are several example config.h files for Amiga,
- X IBM, and Unix. The appropriate one should be copied over CONFIG.H, and
- X the MAKEFILE should be edited for your particular system and compiler
- X configuration before compilation.
- X
- X Version 2.0 has a significant difference from prior releases: Speed!
- X The new primitives of SPHERE, PLANE, TRIANGLE, etc. greatly speed up
- X tracing. Another significant speed-up is that world X-Y-Z values beyond
- X 10 Million or so are ignored, and ray tracing beyond that distance will
- X cease. This produces 2 minor peculiarities:
- X
- X 1) A black stripe at the horizon point of Pre-2.0 scene description
- X .data files that have "ground" and "sky" planes defined. The
- X planes were traced out to a much greater "infinity" so this effect
- X was unnoticeable, prior to version 2.0.
- X 2) Tiny black pixels in the texture, or "Surface Acne".
- X
- X
- X This is usually caused by rays being refracted or reflected such that
- X the ray does not happen to hit any object, and eventually becomes black
- X in color as it gets too far away and gets clipped. This effect can be
- X minimized by enclosing the scene with distant "walls", "floors", or
- X placing "ocean floors" beneath water, etc. So far, no scenes have
- X required placing such planes behind the camera, unless an "environment
- X map" of sorts is desired. See SKYTEST.DAT for several examples of
- X spurious distant planes. If your "acne" still doesn't go away, it may
- X be due to a large pixel sample area and it's accidentally picking a point
- X which is just inside the primitive being hit. This is a more tricky
- X problem to solve, and anti-aliasing the image will definitely help if
- X this sort of thing occurs.
- X
- X For IBM's, the program PICLAB by the Stone Soup Group offers excellent
- X image post-processing features and has direct TARGA 16/24/32 file format
- X compatibility, and will serve to palette map and translate the TARGA
- X images into .GIF's, etc. The commercial application AUTODESK ANIMATOR
- X offers a CONVERT utility that also does an excellent job of palette
- X mapping a TARGA to .GIF format. COLORIX VGA PAINT also offers TARGA
- X format reading and conversion facilities. Those of you with real TARGA
- X boards can view the files directly in 16 million colors and are lucky
- X and should know it!
- X
- X The Stone Soup Group also produces FRACTINT, the best fractal/Mandelbrot
- X program available at ANY price (and it too is FREE!) for the PC. I
- X (AAC) have borrowed their Public Domain .GIF file reading routines for
- X the Image Map texture. Here is their Copyright Notice from the GIF
- X Decoder module:
- X
- X * DECODER.C - An LZW decoder for GIF
- X * Copyright (C) 1987, by Steven A. Bennett
- X *
- X * Permission is given by the author to freely redistribute and include
- X * this code in any program as long as this credit is given where due.
- X *
- X * In accordance with the above, I want to credit Steve Wilhite, who
- X * wrote the code which this is heavily inspired by...
- X *
- X * GIF and 'Graphics Interchange Format' are trademarks (tm) of
- X * Compuserve, Incorporated, an H&R Block Company.
- X
- X
- X
- XSection 0.5 - Program Description:
- X
- X
- X This program is a ray tracer written completely in C. It supports
- X arbitrary quadric surfaces (spheres, ellipsoids, cones, cylinders,
- X planes, etc.), constructive solid geometry, and various shading models
- X (reflection, refraction, marble, wood, and many others). It also has
- X special-case code to handle spheres, planes, triangles, and smooth
- X triangles. By using these special primitives, the rendering can be done
- X much more quickly than by using the more general quadrics.
- X In order to create pictures with this program, you must describe the
- X objects in the world. This description is a text file called
- X "<filename>.data", and <filename> defaults to "object" if not specified.
- X Normally, such files are difficult to write and to read. In order to
- X make this task easier, the program contains a two-pass parser to read
- X the data file. It allows the user to easily create complex worlds from
- X simple components. Since the parser allows include files, the user may
- X put the object descriptions into different files and combine them all
- X into one final image.
- X
- X This manual is divided into four main sections. The first section
- X describes the command-line parameters for the program. The second
- X section describes the syntax and semantics of the description language.
- X Some sample worlds and their corresponding images are provided on the
- X disk. The third section details how to display and convert the images
- X using various postprocesors, and section four has a collection of handy
- X hints for using the tracer most effectively as well as some quick start
- X procedures.
- X
- X
- XSection 1 - Command Line Parameters
- X
- X This program is designed to be run from the CLI, although it can be run
- X from the Workbench if desired. From the CLI, the program accepts
- X various parameters:
- X
- X -wxxx width of the picture in pixels
- X (On the Amiga, use 319 for full-sized pictures)
- X -hxxx height of the picture in pixels
- X (On the Amiga, use 400 for full-sized pictures)
- X
- X +v verbose option - print out the scan line number.
- X -v disable verbose option
- X
- X +f produce an output file
- X -f don't produce an output file
- X
- X If the +f option is used, the ray tracer will produce an
- X output file of the picture. This output file describes each
- X pixel with 24 bits (8 bits for red, 8 for green, and 8 for
- X blue). A post processor (Amiga only) called "DumpToIFF" can
- X convert this format to hi-res HAM format (320 x 400) making
- X reasonable choices for the colour registers. For compati-
- X bility, the format of the dump file is the same as the format
- X for the QRT ray tracer. With Version 2.0, you can substitute
- X the "t" character for the "f" character and produce output
- X files directly in the Truevision (R) TARGA 24 format. This
- X format is remarkably like the QRT/DKB raw format, so it was
- X easily done, and allows for a wider range of post-processing
- X programs to be used. The extension .TGA is normally used for
- X such files, but any may be chosen.
- X
- X +d display the picture while tracing
- X -d don't display the picture while tracing
- X
- X If the +d option is used, then the picture will be displayed
- X while the program performs the ray tracing. On the Amiga,
- X this picture is not as good as the one created by "DumpToIFF"
- X because it does not try to make optimum choices for the colour
- X registers. Version 2.0 will produce a display on an IBM-PS/2
- X compatible VGA/MCGA display in 320x200 x 256 colours if the +d
- X option is given (Anyone for adding in SVGA resolutions??) but
- X the same basic caveat is still applicable: A good post-
- X processor will make better choices of the most popular colors
- X in the image to map to the display.
- X
- X +p wait for prompt (beep and pause) before quitting
- X -p finish without waiting
- X
- X The +p option makes the program wait for a carriage return
- X before exiting (and closing the graphics screen). This gives
- X you time to admire the final picture before destroying it.
- X
- X
- X -ifilename set the input filename
- X -ofilename set output filename
- X
- X If your input file is not "Object.data", then you can use -i
- X to set the filename. The default output filename will be
- X "data.display" on Amiga's, and either "data.dis" or "data.tga"
- X on IBM's, depending on the output file format that is being
- X used. If you want a different output file name, use the -o
- X option.
- X
- X +a[xxx] anti-alias - xxx is an optional tolerance level (default 0.3)
- X -a don't anti-alias
- X
- X The +a option enables adaptive anti-aliasing. The number
- X after the +a option determines the threshold for the anti-
- X aliasing. If the colour of a pixel differs from its neighbor
- X (to the left or above) by more than the threshold, then the
- X pixel is subdivided and super-sampled. The samples are
- X jittered to introduce noise and make the pictures look better.
- X If the anti-aliasing threshold is 0.0, then every pixel is
- X supersampled. If the threshold is 1.0, then no anti-aliasing
- X is done. Good values seem to be around 0.2 to 0.4.
- X
- X +x allow early exit by hitting any key (IBM only)
- X -x lock in trace until finished (IBM only)
- X
- X On the IBM, the -e option disables the ability to abort the
- X trace by hitting a key. If you are unusually clumsy or have
- X CATS that stomp on your keyboard (like I do - AAC :-)), you
- X may want to use it. If you are writing a file, the system
- X will recognize ^C at the end of line if BREAK is on (on the
- X IBM). If you aren't writing a file, you won't be able to
- X abort the trace until it's done.
- X
- X This option was meant for big, long late-nite traces that take
- X ALL night (or longer!), and you don't want them interrupted by
- X anything less important than a natural disaster such as hur-
- X ricane, fire, flood, famine, etc.
- X
- X -bxxx use an output file buffer of xxx kilobytes.
- X (if 0, flush the file on every line - this is the default)
- X
- X The -b option allows you to assign large buffers to the output
- X file. This reduces the amount of time spent writing to the
- X disk and prevents unnecessary wear (especially for floppies).
- X If this parameter is zero, then as each scanline is finished,
- X the line is written to the file and the file is flushed. On
- X most systems, this operation insures that the file is written
- X to the disk so that in the event of a system crash or other
- X catastrophic event, at least part of the picture has been
- X stored properly on disk.
- X
- X
- X -sxxx start tracing at line number xxx.
- X -exxx end tracing at line number xxx.
- X
- X The -s option is provided for when some natural or unnatural
- X catastrophe has occurred, and you want to restart the trace at
- X a given line number after the crash. One is subtracted from
- X the given line number if anti-aliasing is activated (the prior
- X line's being computed is required for the anti-aliasing mech-
- X anism to function properly). It can also be used to re-render
- X parts of an image (perhaps with anti-aliasing turned on). A
- X separate utility can then merge the new lines into the old
- X file. The particularly faint of heart or weak of power supply
- X may want to batch the image in "strips" of 10-20 lines and
- X concatenate them later.
- X
- X -qx rendering quality
- X
- X The -q option allows you to specify the image rendering
- X quality. The parameter can range from 0 to 9. The values
- X correspond to the following quality levels:
- X
- X 0,1 Just show colours. Ambient lighting only.
- X 2,3 Show Diffuse and Ambient light
- X 4,5 Render shadows
- X 6,7 Create surface textures
- X 8,9 Compute reflected, refracted, and transmitted rays.
- X
- X The default is -q9 (maximum quality) if not specified.
- X
- X You may specify the default parameters by modifying the file
- X "trace.def" which contains the parameters in the above format.
- X This filename contains a complete command line as though you
- X had typed it in, and is processed before any options supplied
- X on the command line are recognized.
- X
- X
- X
- X
- XSection 2 - The Object Description Language
- X
- X The Object Description Language allows the user to describe the world in
- X a readable and convenient way.
- X
- X The language delimits comments by the left and right braces ({ and }).
- X Nested comments are allowed, but no sane person uses them anyway, right?
- X
- X The language allows include files to be specified by placing the line:
- X
- X INCLUDE "filename"
- X
- X at any point in the input file (Include files may be nested).
- X
- X
- XSection 2.1 - The Basic Data Types
- X
- X There are several basic types of data:
- X
- X Float
- X Floats are represented by an optional sign (+ or -), some digits, an
- X optional decimal point, and more digits. It does not support the "e"
- X notation for exponents. The following are valid floats:
- X
- X 1.0 -2.0 -4 +34
- X
- X Vector
- X Vectors are arrays of three floats. They are bracketed by angle
- X brackets ( < and > ), and the three terms usually represent x, y, and z.
- X For example:
- X
- X < 1.0 3.2 -5.4578 >
- X
- X Colour
- X A colour consists of a red component, a green component, a blue
- X component, and possibly an alpha component. All four components are
- X floats in the range 0.0 to 1.0. The syntax for Colours is the word
- X "COLOUR" followed by any or all of the RED, GREEN, BLUE or ALPHA
- X components in any order.
- X
- X For example:
- X
- X COLOUR RED 1.0 GREEN 1.0 BLUE 1.0
- X COLOUR BLUE 0.56
- X COLOUR GREEN 0.45 RED 0.3 ALPHA 0.3
- X
- X Alpha is a transparency indicator. If an object's colour contains some
- X transparency, then you can see through it. If Alpha is 0.0, the object
- X is totally opaque. If it is 1.0, it is totally transparent.
- X
- X For those people who spell "Colour" the American way as "Color", the
- X program also accepts "COLOR" as equivalent to "COLOUR" in all instances.
- X
- X COLOUR_MAP
- X For wood, marble, spotted, agate, granite, and gradient texturing, the
- X user may specify arbitrary colours to use for the texture. This is done
- X by a colour map or "colour spline". When the object is being textured,
- X a number between 0.0 and 1.0 is generated which is then used to form the
- X colour of the point. A Colour map specifies the mapping used to change
- X these numbers into colours. The syntax is as follows:
- X
- X COLOUR_MAP
- X [start_value end_value colour1 colour2]
- X [start_value end_value colour1 colour2]
- X ...
- X END_COLOUR_MAP
- X
- X The value is located in the colour map and the final colour is
- X calculated by a linear interpolation between the two colours in the
- X located range.
- X
- XSection 2.2 - The More Complex Data Types
- X
- X The data types used to describe the objects in the world are a bit more
- X difficult to describe. To make this task easier, the program allows
- X users to describe these types in two ways. The first way is to define
- X it from first principles specifying all of the required parameters. The
- X second way allows the user to define an object as a modification of
- X another object (the other object is usually defined from first
- X principles but is much simpler). Here's how it works:
- X
- X You can use the term DECLARE to declare a type of object with a certain
- X description. The object is not included in the world but it can be used
- X as a "prototype" for defining other objects, as this basic example
- X shows:
- X
- X DECLARE Sphere = QUADRIC
- X <1.0 1.0 1.0>
- X <0.0 0.0 0.0>
- X <0.0 0.0 0.0>
- X -1.0
- X END_QUADRIC
- X
- X To then reference the declaration elsewhere in your source file or in
- X another included one, and to actually include the object in the world,
- X you would define the object using object definition syntax, like this:
- X
- X OBJECT
- X QUADRIC Sphere
- X SCALE <20.0 20.0 20.0>
- X END_QUADRIC
- X COLOUR White
- X AMBIENT 0.2
- X DIFFUSE 0.8
- X END_OBJECT
- X The real power of declaration becomes apparent when you declare several
- X primitive types of objects and then define an object with several
- X component shapes, using either COMPOSITE methods or the CSG methods
- X INTERSECTION, UNION, or DIFFERENCE. More on those later. Also, using
- X the DECLARE keyword can make several objects share a texture without the
- X need for each object to store a duplicate copy of the same texture, for
- X more efficient memory usage. Example:
- X
- X OBJECT { A Hot dog in a Hamburger Bun (?) }
- X UNION
- X QUADRIC Sphere
- X SCALE <20.0, 10.0, 20.0>
- X END_QUADRIC
- X QUADRIC Cylinder_X
- X SCALE <40.0, 20.0, 20.0>
- X END_QUADRIC
- X END_UNION
- X END_OBJECT
- X
- X
- X Viewpoint
- X The viewpoint tells the ray tracer the location and orientation of the
- X camera. The viewpoint is described by four vectors - Location,
- X Direction, Up, and Right. Location determines where the camera is
- X located. Direction determines the direction that the camera is
- X pointed. Up determines the "up" direction of the camera. Right
- X determines the direction to the right of the camera.
- X
- X A first principle's declaration of a viewpoint would look like this:
- X
- X VIEWPOINT
- X LOCATION < 0.0 0.0 0.0>
- X DIRECTION < 0.0 0.0 1.0>
- X UP < 0.0 1.0 0.0 >
- X RIGHT < 1.0 0.0 0.0>
- X END_VIEWPOINT
- X
- X This format becomes cumbersome, however, because the vectors must be
- X calculated by hand. This is especially difficult when the vectors are
- X not lined up with the X, Y, and Z axes as they are in the above example.
- X To make it easier to define the viewpoint, you can define one viewpoint,
- X then modify the description. For example,
- X
- X VIEWPOINT
- X LOCATION < 0.0 0.0 0.0>
- X DIRECTION < 0.0 0.0 1.0>
- X UP < 0.0 1.0 0.0 >
- X RIGHT < 1.0 0.0 0.0 >
- X TRANSLATE < 5.0 3.0 4.0 >
- X ROTATE < 30.0 60.0 30.0 >
- X END_VIEWPOINT
- X
- X In this example, the viewpoint is created, then translated to another
- X point in space and rotated by 30 degrees about the X axis, 60 degrees
- X about the Y axis, and 30 degrees about the Z axis.
- X
- X Unfortunately, even this is somewhat cumbersome. So, in version 2.0,
- X you can now specify two more parameters:
- X
- X SKY <vector>
- X LOOK_AT <vector>
- X
- X The SKY keyword tells the viewpoint where the sky is. It tries to keep
- X the camera's UP direction aligned as closely as possible to the sky.
- X The LOOK_AT keyword tells the camera to look at a specific point. The
- X camera is rotated as required to point directly at that point. By
- X changing the SKY vector, you can twist the camera while still looking
- X at the same point.
- X
- X Note that a pinhole camera model is used, so no focus or depth-of-field
- X effects are supported at this time.
- X
- X
- X Version 2.0 of the raytracer includes the ability to render fog. To add
- X fog to a scene, place the following declaration outside of any object
- X definitions:
- X
- X FOG
- X COLOUR ... the fog colour
- X 200.0 ... the fog distance
- X END_FOG
- X
- X Shapes
- X Shapes describe the shape of an object without mentioning any surface
- X characteristics like colour, lighting and reflectivity. The most
- X general shape used by this system is called a Quadric Surface. Quadric
- X Surfaces can produce shapes like spheres, cones, and cylinders. The
- X easiest way to define these shapes is to include the standard file
- X "BasicShapes.data" into your program and to transform these shapes
- X (using TRANSLATE, ROTATE, and SCALE) into the ones you want. To be
- X complete, however, I will describe the mathematical principles behind
- X quadric surfaces. Those who are not interested in the mathematical
- X details can skip to the next section.
- X
- X A quadric surface is a surface in three dimensions which satisfies the
- X following equation:
- X
- X
- X A y**2 + B y**2 + C z**2
- X + D xy + E xz + F yz
- X + G x + H y + I z + J = 0
- X
- X
- X (Did you really want to know that? I didn't think so. :-) DKB)
- X
- X Different values of A,B,C,...J will give different shapes. So, if you
- X take any three dimensional point and use its x, y, and z coordinates in
- X the above equation, the answer will be 0 if the point is on the surface
- X of the object. The answer will be negative if the point is inside the
- X object and positive if the point is outside the object. Here are some
- X examples:
- X
- X X**2 + Y**2 + Z**2 - 1 = 0 Sphere
- X X**2 + Y**2 - 1 = 0 Cylinder along the Z axis
- X X**2 + Y**2 + Z = 0 Cone along the Z axis
- X
- X General quadric surfaces can be defined as follows:
- X
- X QUADRIC
- X < A B C >
- X < D E F >
- X < G H I >
- X J
- X END_QUADRIC
- X
- X
- XSection 2.3 - Quadric surfaces the easy way
- X
- X Now that doesn't sound so hard, does it? Well, actually, it does. Only
- X the hard-core graphics fanatic would define his objects using the
- X QUADRIC definition directly. Even I don't do it that way and I know how
- X it works (Well, at least I worked it out once or twice :-) - DKB).
- X
- X Fortunately, there is an easier way. The file "BasicShapes.data" already
- X includes the definitions of many quadric surfaces. They are centered
- X about the origin (0,0,0) and have a radius of 1. To use them, you can
- X define shapes as follows:
- X
- X
- X INCLUDE "BasicShapes.data"
- X
- X QUADRIC
- X Cylinder_X
- X SCALE < 50.0 50.0 50.0 >
- X ROTATE < 30.0 10.0 45.0 >
- X TRANSLATE < 2.0 5.0 6.0 >
- X END_QUADRIC
- X
- X
- X You may have as many transformation lines (scale, rotate, and translate)
- X as you like in any order. Usually, however, it's easiest to do a scale
- X first, one or more rotations, then finally a translation. Otherwise,
- X the results may not be what you expect. (The transformations always
- X transform the object about the origin. If you have a sphere at the
- X origin and you translate it then rotate it, the rotation will spin the
- X sphere around the origin like planets about the sun).
- X
- X
- X
- XSection 2.4 - Spheres
- X
- X Since spheres are so common in ray traced graphics, A SPHERE primitive
- X has been added to the system. This primitive will render much more
- X quickly than the corresponding quadric shape. The syntax is:
- X
- X SPHERE <center> radius END_SPHERE
- X
- X You can also add translations, rotations, and scaling to the sphere.
- X For example, the following two objects are identical:
- X
- X OBJECT
- X SPHERE < 0.0 25.0 0.0 > 10.0 END_SPHERE
- X COLOR Blue
- X AMBIENT 0.3
- X DIFFUSE 0.7
- X END_OBJECT
- X
- X OBJECT
- X SPHERE < 0.0 0.0 0.0 > 1.0
- X TRANSLATE <0.0 25.0 0.0>
- X SCALE <10.0 10.0 10.0>
- X END_SPHERE
- X COLOR Blue
- X AMBIENT 0.3
- X DIFFUSE 0.7
- X END_OBJECT
- X
- X Note that Spheres may only be scaled uniformly. You cannot use:
- X
- X SCALE <10.0 5.0 2.0>
- X
- X on a sphere. If you need oblate spheroids such as this, use a scaled
- X quadric "Sphere" shape instead.
- X
- XSection 2.5 - Planes
- X
- X Another primitive provided to speed up the raytracing is the PLANE.
- X This is a flat infinite plane. To declare a PLANE, you specify the
- X direction of the surface normal to the plane (the UP direction) and the
- X distance from the origin of the plane to the world's origin. As with
- X spheres, you can translate, rotate, and scale planes. Examples:
- X
- X PLANE <0.0 1.0 0.0> -10.0 END_PLANE { A plane in the X-Z axes 10
- X units below the world origin. }
- X
- X PLANE <0.0 1.0 0.0> 10.0 END_PLANE { A plane in the X-Z axes 10
- X units above the world origin. }
- X
- X PLANE <0.0 0.0 1.0> -10.0 END_PLANE { A plane in the X-Y axes 10
- X units behind the world origin.}
- X
- X
- XSection 2.6 - Triangles
- X
- X In order to make more complex objects than the class of quadrics will
- X permit, a new primitive shape for triangles has been added. There are
- X two different types of triangles: flat shaded triangles and smooth
- X shaded (Phong) triangles.
- X
- X Flat shaded triangles are defined by listing the three vertices of the
- X triangle. For example:
- X
- X TRIANGLE < 0.0 20.0 0.0>
- X < 20.0 0.0 0.0>
- X <-20.0 0.0 0.0>
- X END_TRIANGLE
- X
- X The smooth shaded triangles use Phong Normal Interpolation to calculate
- X the surface normal for the triangle. This makes the triangle appear to
- X be a smooth curved surface. In order to define a smooth triangle,
- X however, you must supply not only the vertices, but also the surface
- X normals at those vertices. For example:
- X
- X SMOOTH_TRIANGLE
- X { points surface normals }
- X < 0.0 30.0 0.0 > <0.0 0.7071 -0.7071>
- X < 40.0 -20.0 0.0 > <0.0 -0.8664 -0.5 >
- X <-50.0 -30.0 0.0 > <0.0 -0.5 -0.8664>
- X END_SMOOTH_TRIANGLE
- X
- X As with the other shapes, triangles can be translated, rotated, and
- X scaled.
- X
- X NOTE: Triangles cannot be used in CSG INTERSECTION or DIFFERENCE types
- X (described next) since triangles have no clear "inside". The CSG UNION
- X type works acceptably but with no difference from a COMPOSITE object.
- X
- X
- XSection 2.7 - Constructive Solid Geometry (CSG)
- X
- X This ray tracer supports Constructive Solid Geometry in order to make
- X the object definition abilities more powerful. Constructive Solid
- X Geometry allows you to define shapes which are the union, intersection,
- X or difference of other shapes. Unions superimpose the two shapes. This
- X has the same effect as defining two separate objects, but is simpler to
- X create and/or manipulate. Intersections define the space where the two
- X surfaces meet. Differences allow you to cut one object out of another.
- X
- X
- X
- X
- X
- X
- X
- X
- X CSG Intersections, Unions, and Differences can consist of two or more
- X shapes. They are defined as follows:
- X
- X OBJECT
- X INTERSECTION
- X QUADRIC
- X ...
- X END_QUADRIC
- X
- X QUADRIC
- X ...
- X END_QUADRIC
- X
- X QUADRIC
- X ...
- X END_QUADRIC
- X END_INTERSECTION
- X ...
- X END_OBJECT
- X
- X UNION or DIFFERENCE may be used instead of INTERSECTION. The order of
- X the shapes doesn't matter except for the DIFFERENCE shapes. For CSG
- X differences, the first shape is visible and the remaining shapes are cut
- X out of the first (in reverse order from version 1.2 DIFFERENCE's).
- X
- X Constructive solid geometry shapes may be translated, rotated, or scaled
- X in the same way as a Quadric surface. The quadric surfaces making up
- X the CSG object may be individually translated, rotated, and scaled as
- X well.
- X
- X When using CSG, it is often useful to invert an shape so that it's
- X inside-out. The INVERSE keyword can be used to do this for any SPHERE,
- X PLANE, or QUADRIC. When INVERSE is used, the "inside" of the object is
- X flipped to be the "outside". For Planes, "inside" is defined to be "in
- X the opposite direction to the "normal" or "up" direction.
- X
- X Note that performing an INTERSECTION between an shape and some other
- X INVERSE shapes is the same as performing a DIFFERENCE. In fact, the
- X DIFFERENCE is actually implemented in this way.
- X
- XSection 2.8 - Objects
- X
- X There is more to defining an object than just its shape. You must tell
- X the ray tracer about the properties of the surface like colour, alpha,
- X reflectivity, refractivity, the index of refraction, and so on. To do
- X this, you must define Objects.
- X
- X
- X
- X
- X
- X
- X
- X A typical object definition looks something like this:
- X
- X OBJECT
- X QUADRIC Sphere
- X TRANSLATE < 40.0 40.0 60.0 >
- X END_QUADRIC
- X
- X TEXTURE
- X 0.05
- X END_TEXTURE
- X
- X AMBIENT 0.3
- X DIFFUSE 0.7
- X REFLECTION 0.3
- X REFRACTION 0.3
- X IOR 1.05
- X COLOUR RED 1.0 GREEN 1.0 BLUE 1.0 ALPHA 0.5
- X END_OBJECT
- X
- X The following keywords may be used when defining objects:
- X
- X AMBIENT value
- X - Ambient light is light that is scattered everywhere in the room.
- X An object lit only by ambient light will appear to have the same
- X brightness over the entire surface. The default value is very
- X little ambient light (0.3). The value can range from 0.0 to 1.0.
- X
- X DIFFUSE value
- X - Diffuse light is light coming from a light source that is scattered
- X in all directions. An object lit only by diffuse light looks like
- X a rubber ball with a spot light shining on it. The value can range
- X from 0.0 to 1.0. By default, there is mostly diffuse lighting
- X (0.7).
- X
- X BRILLIANCE value
- X - Objects can be made to appear more metallic by increasing their
- X brilliance. This controls the tightness of the basic diffuse
- X illumination on objects and minorly adjusts the appearance of
- X surface shininess. The default value is 1.0. Higher values from
- X 3.0 to about 10.0 can give objects a somewhat more shiny or
- X metallic appearance. This is best used in concert with either
- X SPECULAR or PHONG highlighting.
- X
- X REFLECTION value
- X - By setting the reflection value to be non-zero, you can give the
- X object a mirrored finish. It will reflect all other objects in the
- X room. The value can range from 0.0 to 1.0. By default there is no
- X reflection.
- X
- X
- X
- X
- X
- X REFRACTION value
- X - By setting the refraction value to be non-zero, the object is made
- X transparent. Light will be refracted through the object like a
- X lens. The value can be set between 0.0 and 1.0. There is no
- X refraction by default.
- X IOR value
- X - If the object is refracting light, then the IOR or Index of
- X Refraction should be set. This determines how dense the object is.
- X A value of 1.0 will give no refraction. The Index of Refraction
- X for Air is 1.0, Water is 1.33, glass is 1.5, and diamond is 2.4.
- X
- X PHONG value
- X - Controls the amount of Phong Specular Reflection highlighting on
- X the object. Causes bright shiny spots on the object, the colour of
- X the light source that is being reflected. The size of the spot is
- X defined by the value given for PHONGSIZE below. PHONG's value is
- X typically from 0.0 to 1.0, where 1.0 causes complete saturation of
- X the object's colour to the light source's colour at the brightest
- X area (center) of the highlight. There is no PHONG highlighting
- X given by default.
- X
- X PHONGSIZE value
- X - Controls the size of the PHONG Highlight on the object, sort of an
- X arbitrary "glossiness" factor. Values range from 1.0 (Very Dull)
- X to 100 (Highly Polished). Default PHONGSIZE is 40 (plastic?) if
- X not specified. This is simulating the fact that slightly reflect-
- X ive objects, especially metallic ones, have microscopic facets,
- X some of which are facing in the mirror direction. The more that
- X are facing that way, the shinier the object appears, and the
- X tighter the specular highlights become. Phong measures the average
- X of facets facing in the mirror direction from the light sources to
- X the viewer.
- X
- X SPECULAR value
- X - Very similar to PHONG Specular Highlighting, but a better model is
- X used for determining light ray/object intersection, so a more
- X credible spreading of the highlights occur near the object
- X horizons, supposedly. PHONG is thus included for mostly academic
- X reasons, but try them both and you decide which you like better.
- X This effect is most obvious for light sources behind objects. The
- X size of the spot is defined by the value given for ROUGHNESS below.
- X Like PHONG, SPECULAR values are typically from 0.0 to 1.0 for full
- X saturation. Default is no SPECULAR highlighting.
- X
- X ROUGHNESS value
- X - Controls the size of the SPECULAR Highlight on the object, relative
- X to the object's "roughness". Values range from 1.0 (Very Rough) to
- X 0.001 (Very Smooth). The default value if not specified is 0.05
- X (Plastic?). The roughness or average directional distribution of
- X the microfacets is facing in the same direction as the perpen-
- X dicular surface "normal" cause the most notable reflection of the
- X highlight to the observer.
- X
- X COLOUR value
- X - The colour of an object can be set by using this option. The value
- X is a colour or a colour constant. For example:
- X
- X COLOUR RED 1.0 BLUE 0.4
- X
- X - or -
- X
- X DECLARE Yellow = COLOUR RED 1.0 GREEN 1.0
- X ...
- X COLOUR Yellow
- X
- X
- X TRANSLATE vector
- X ROTATE vector
- X SCALE vector
- X - Objects can be translated, rotated, and scaled just like surfaces.
- X This feature is included for consistency.
- X
- X LIGHT_SOURCE
- X - If the LIGHT_SOURCE keyword is used in the definition of an object,
- X then the object is included in the list of light sources. It can
- X light objects and produce shadows. (You should also specify the
- X COLOUR of the light source). Light sources have a peculiar re-
- X striction: The light source MUST be TRANSLATED to it's final
- X position in the scene, so the normal way to define a light source
- X is a sphere or quadric centered about the origin, then TRANSLATED
- X to where desired in the final scene. For example:
- X
- X OBJECT
- X SPHERE <0.0 0.0 0.0> 2.0 END_SPHERE {could be a quadric, too.}
- X TRANSLATE <100.0 120.0 40.0>
- X
- X LIGHT_SOURCE
- X COLOUR RED 1.0 GREEN 1.0 BLUE 1.0
- X AMBIENT 1.0
- X DIFFUSE 0.0
- X END_OBJECT
- X
- X
- X TEXTURE
- X - The texture feature is an experiment into functionally based
- X modelling. This feature allows you to assign more interesting
- X colouring schemes to objects. Many procedural surface textures are
- X provided, and by using different colour maps with them, nearly
- X infinite permutations are possible. For example, you can make some
- X object look like wood or marble, etc.
- X
- X
- X
- X
- X
- X
- X The basic TEXTURE syntax is as follows:
- X
- X TEXTURE
- X 0.05
- X WOOD
- X TURBULENCE 0.2
- X TRANSLATE < 1.0 2.0 3.0 >
- X ROTATE < 0.0 10.0 40.0 >
- X SCALE < 10.0 10.0 10.0 >
- X END_TEXTURE
- X
- X The transformations are optional. They allow you to transform the
- X texture independent of the object itself. If you are doing animation,
- X then the transformations should be the same as the object
- X transformations so that the texture follows the object.
- X
- X The floating-point value given immediately following the texture keyword
- X is an optional "texture randomness" value, which causes a minor random
- X scattering of calculated colour values and produces a sort of "dithered"
- X appearance.
- X
- X Instead of using WOOD, you may use MARBLE, BOZO, CHECKER, or a handful
- X of other interesting textures. The WOOD and MARBLE textures are
- X perturbed by a turbulence function. This makes them look more random
- X and irregular than they would normally appear. The amount of turbulence
- X can be changed by the TURBULENCE keyword followed by a number. Values
- X from 0.1 to 0.3 seem to give the best results. The default is 0.0, or
- X no turbulence.
- X
- X Note some of the textures given are coloration textures, such as MARBLE,
- X WOOD CHECKER, GRANITE, and AGATE. These work with colour maps, and have
- X default "colour maps" they resort to if none are given. The rest of the
- X textures available are "surface perturbation" textures, and do not dir-
- X ectly affect the colour of the object, but rather the surface's apparent
- X orientation in space. Examples of this are WAVES, RIPPLES, DENTS, BUMPS,
- X and WRINKLES. Note that any given texture may include up to two actual
- X textures, one coloration and one surface perturbation choice per
- X texture. This would allow rippled wood, or dented granite combinations,
- X etc., but keep in mind that any transformations applied to one texture
- X (i.e. TRANSLATE or SCALE) will also transform the other one in the same
- X fashion.
- X
- X
- X The following textures are available:
- X
- X CHECKER texturing gives a checker-board appearance. This option works
- X best on planes. When using the CHECKER texturing, you must specify two
- X colours immediately following the word CHECKER. These colours are the
- X colours of alternate squares in the checker pattern. The default
- X orientation of the CHECKER texture is on an X-Z plane (good for ground
- X work, etc.) but to use it on an object which has mostly X-Y orientation
- X (such as a sphere, for instance), you must ROTATE the texture.
- X
- X To rotate the CHECKER texture onto an X-Y plane:
- X
- X TEXTURE
- X CHECKER COLOUR White COLOUR Red
- X SCALE <10.0 10.0 10.0>
- X ROTATE <-90.0 0.0 0.0> { Checkers now in the X-Y plane... }
- X END_TEXTURE
- X
- X As mentioned above, for coloration textures such as WOOD, MARBLE, and
- X BOZO, etc., you may change the colouring scheme by using a colour map.
- X This map allows you to convert numbers from 0.0 to 1.0 (which are
- X generated by the ray tracer) into ranges of colours. For example, the
- X default BOZO colouring can be specified by:
- X
- X TEXTURE
- X BOZO
- X COLOUR_MAP
- X [0.0 0.4 COLOUR White COLOUR White]
- X [0.4 0.6 COLOUR Green COLOUR Green]
- X [0.6 0.8 COLOUR Blue COLOUR Blue]
- X [0.8 1.0 COLOUR Red COLOUR Red]
- X END_COLOUR_MAP
- X END_TEXTURE
- X
- X BOZO texture basically takes a noise function and maps it onto the
- X surface of an object. This "noise" is defined for every point in space.
- X If two points are close together, they will have noise values that are
- X close together. If they are far apart, their noise values will be
- X fairly random relative to each other.
- X
- X The easiest way to see how it works is to try it. With a good choice of
- X colours it produces some of the most realistic looking cloudscapes you
- X have ever seen. Try a cloud color map such as:
- X
- X TEXTURE
- X BOZO
- X TURBULENCE 1.0 { A blustery day. For a calmer one, try 0.2 }
- X COLOUR_MAP
- X [0.0 0.5 COLOUR RED 0.5 GREEN 0.5 BLUE 1.0 {blue to blue}
- X COLOUR RED 0.5 GREEN 0.5 BLUE 1.0]
- X [0.5 0.6 COLOUR RED 0.5 GREEN 0.5 BLUE 1.0 {blue to white}
- X COLOUR RED 1.0 GREEN 1.0 BLUE 1.0]
- X [0.6 1.001 COLOUR RED 1.0 GREEN 1.0 BLUE 1.0 {white to grey}
- X COLOUR RED 0.5 GREEN 0.5 BLUE 0.5]
- X END_COLOUR_MAP
- X SCALE <800.0 800.0 800.0>
- X TRANSLATE <200.0 400.0 100.0>
- X END_TEXTURE
- X
- X (Check out sunset.dat for a really neat (but slow) sky pattern)
- X
- X
- X
- X The color map above indicates that for small values of texture, use a
- X sky blue color solidly until about halfway turbulent, then fade through
- X to white on a fairly narrow range. As the white clouds get more turb-
- X ulent and solid towards the center, pull the color map toward grey to
- X give them the appearance of holding water vapor (like typical clouds).
- X SPOTTED - Spotted texture is a sort of swirled random spotting of the
- X colour of the object. If you've ever seen a metal organ pipe you know
- X about what it looks like (a galvanized garbage can is close...) Play
- X with this one, it might render a decent cloudscape during a very stormy
- X day (?). No extra keywords are required. Should work with colour maps.
- X With small scaling values, looks like masonry or concrete.
- X
- X AGATE - this texture is similar to Marble, but uses a different turb-
- X ulence function. The TURBULENCE keyword has no effect, and as such it
- X is always very turbulent.
- X
- X GRADIENT - this is a specialized texture that uses approximate local
- X coordinates of an object to control colour map gradients. This texture
- X ONLY works with colour maps (one MUST be given!) and has a special <X,
- X Y, Z> triple given after the GRADIENT keyword, which specifies any (or
- X all) axes to perform the gradient action on. (Example: a Y gradient
- X <0.0, 1.0, 0.0> will give an "altitude colour map", along the Y axis).
- X Values other than 0.0 are taken as 1.0 and others are meaningless. For
- X smooth repeating gradients, you should use a nearly "circular" colour
- X map, that is, one in which the first colour value (0.0) is the same as
- X the last one (1.001) so it "wraps around" and will cause smooth
- X repeating gradient patterns. Scaling the texture is normally required
- X to achieve the number of repeating shade cycles you want.
- X Transformation of the texture is useful to prevent a "mirroring" effect
- X from either side of the central 0 axes. Here is an example of a
- X gradient texture which uses a sharp "circular" color mapped gradient
- X rather than a smooth one, and uses both X and Y gradients to get a
- X diagonally-oriented gradient. It produces a dandy candy cane texture!
- X
- X TEXTURE
- X GRADIENT < 1.0 1.0 0.0 >
- X COLOUR_MAP
- X [0.00 0.25 COLOUR RED 1.0 GREEN 0.0 BLUE 0.0
- X COLOUR RED 1.0 GREEN 0.0 BLUE 0.0]
- X [0.25 0.75 COLOUR RED 1.0 GREEN 1.0 BLUE 1.0
- X COLOUR RED 1.0 GREEN 1.0 BLUE 1.0]
- X [0.75 1.001 COLOUR RED 1.0 GREEN 0.0 BLUE 0.0
- X COLOUR RED 1.0 GREEN 0.0 BLUE 0.0]
- X END_COLOUR_MAP
- X SCALE <30.0 30.0 30.0>
- X TRANSLATE <30.0 -30.0 0.0>
- X END_TEXTURE
- X
- X
- X You may also specify a TURBULENCE value with the gradient to give a
- X more irregular colour gradient. This may help to do neat things like
- X fire or coronas.
- X
- X GRANITE - A colouring texture. This uses a simple 1/f fractal noise
- X function to give a pretty darn good grey granite texture. Typically
- X used with small scaling values (2.0 to 5.0). Also looks good with a
- X little dithering (texture randomness). Should work with colour maps, so
- X try your hand at pink granite or alabaster!
- X
- X RIPPLES - As mentioned above, you may optionally specify a surface
- X perturbation texture which can be used in conjunction with the above
- X coloration textures. RIPPLES is one example of a surface perturbation
- X texture. This texture makes the surface look like ripples of water.
- X The RIPPLES option requires a value to determine how deep the ripples
- X are:
- X
- X TEXTURE
- X WOOD
- X RIPPLES 0.3
- X TRANSLATE < 1.0 2.0 3.0 >
- X ROTATE < 0.0 10.0 40.0 >
- X SCALE < 10.0 10.0 10.0 >
- X END_TEXTURE
- X
- X (In this case, the WOOD, MARBLE, or BOZO, etc. keywords are optional).
- X If a different colouring is specified (WOOD, MARBLE, or BOZO), then the
- X COLOUR parameter is ignored (except for light sources where it gives the
- X light colour or when rendering with a low -q option).
- X
- X WAVES - Another option that you may want to experiment with is called
- X WAVES. This works in a similar way to RIPPLES except that it makes waves
- X with different frequencies. The effect is to make waves that look more
- X like deep ocean waves. (I haven't done much testing on WAVES, so I can't
- X guarantee that it works very well).
- X
- X Both WAVES and RIPPLES respond to a texturing option called PHASE. The
- X PHASE option allows you to create animations in which the water seems to
- X move. This is done by making the PHASE increment slowly between frames.
- X The range from 0.0 to 1.0 gives one complete cycle of a wave.
- X
- X BUMPS - Approximately the same turbulence function as SPOTTED, but uses
- X the derived value to perturb the surface normal. This gives the
- X impression of a "bumpy" surface, random and irregular, sort of like an
- X orange. After the BUMPS keyword, supply a single floating point value
- X for the amount of surface perturbation. Values typically range from 0.0
- X (No Bumps) to 1.0 (Extremely Bumpy). Values beyond 1.0 may do wierd
- X things.
- X
- X DENTS - Also a surface normal perturbing texture. Interesting when used
- X with metallic textures, it gives impressions into the metal surface that
- X look like dents. A single value is supplied after the DENTS keyword to
- X indicate the amount of denting required. Values range from 0.0 (No
- X Dents) to 1.0 (Fairly Dented). Use larger values at your own risk...
- X Scale the texture to make the pitting more or less frequent.
- X
- X
- X WRINKLES - This is sort of a 3-D (normal perturbing) GRANITE. It uses
- X a similar 1/f fractal noise function to perturb the surface normal in 3D
- X space. With ALPHA values of greater than 0.0, could look like wrinkled
- X cellophane. Requires a single value after the WRINKLES keyword to
- X indicate the amount of wrinkling desired. Values from 0.0 (No Wrinkles)
- X to 1.0 (Very Wrinkled) are typical.
- X
- X
- X IMAGEMAP - This is a very special coloration texture that allows you to
- X import a bitmapped file in RAW format (the format output by the ray-
- X tracer), IFF format or Compuserve GIF format and map that bitmap onto an
- X object. In the texture of an object, you must give the IMAGEMAP key-
- X word, the format, and a file name. The syntax is:
- X
- X IMAGEMAP [gradient] RAW "filename [ONCE]"
- X or IMAGEMAP [gradient] IFF "filename [ONCE]"
- X or IMAGEMAP [gradient] GIF "filename [ONCE]"
- X
- X The texture will then be mapped onto the object as a repeating pattern.
- X The ONCE keyword places only one image onto the object instead of an
- X infinitely repeating tiled pattern. When ONCE is used, the object's
- X default colour is used as the colour outside of the image.
- X
- X
- X By default, the image is mapped onto the XY plane in the range (0.0,
- X 0.0) to (1.0, 1.0). If you would like to change this default, you may
- X use an optional gradient <x, y, z> vector after the word IMAGEMAP. This
- X vector indicates which axes are to be used as the u and v (local surface
- X X-Y) axes. The vector should contain one positive number and one
- X negative number to indicate the u and v axes, respectively. You may
- X translate, rotate, and scale the texture to map it onto the object's
- X surface as desired. Here is an example:
- X
- X INCLUDE "BasicShapes.data"
- X
- X OBJECT
- X QUADRIC Plane_XY END_QUADRIC
- X TRANSLATE <0.0 -20.0 0.0>
- X
- X TEXTURE
- X { make this texture use the x and z axes for the mapping. }
- X IMAGEMAP <1.0 0.0 -1.0> GIF "image.gif"
- X SCALE <40.0 40.0 40.0>
- X END_TEXTURE
- X END_OBJECT
- X
- X When I was bored with nothing to do, I decided that it would be neat to
- X have turbulent texture maps. So, I said - "what the hell!" You can
- X specify TURBULENCE with texture maps and it will perturb the image. It
- X may give some bizarre results. Is this useful? I dunno. It was easy
- X to do so I did it. Try it out and see what you get.
- X
- XSection 2.9 - Composite Objects
- X
- X Often it's useful to combine several objects together to act as a whole.
- X A car, for example, consists of wheels, doors, a roof, etc. A composite
- X object allows you to combine all of these pieces into one object. This
- X has two advantages. It makes it easier to move the object as a whole
- X and it allows you to speed up the ray tracing by defining bounding
- X shapes that contain the objects. (Rays are first tested to see if they
- X intersect the bounding shape. If not, the entire composite object is
- X ignored). Composite objects are defined as follows:
- X
- X COMPOSITE
- X OBJECT
- X ...
- X END_OBJECT
- X
- X OBJECT
- X ...
- X END_OBJECT
- X ...
- X
- X SCALE < 2.0 2.0 2.0 >
- X ROTATE < 30.0 45.0 160.0 >
- X TRANSLATE < 100.0 20.0 40.0 >
- X END_COMPOSITE
- X
- X Composite objects can contain other composite objects as well as regular
- X objects. Composite objects cannot be light sources (although any number
- X of their components can). This is because it is nearly impossible to
- X determine the true "center" of the composite object, and our light
- X sources are pinpoint ray sources from the center of the light source
- X object, wherever that may be.
- X
- X
- XSection 2.95 - Bounding Shapes
- X
- X Let's face it. This program is no speed demon. You can save yourself
- X a lot of time, however, if you use bounding shapes around any complex
- X objects. Bounding shapes tell the ray tracer that the object is totally
- X enclosed by a simple shape. When tracing rays, the ray is first tested
- X against the simple bounding shape. If it strikes the bounding shape,
- X then the ray is further tested against the more complicated object
- X inside.
- X
- X To use bounding shapes, you simply include the following lines into the
- X declaration of your OBJECT or COMPOSITE_OBJECT:
- X
- X BOUNDED_BY
- X a shape
- X END_BOUND
- X
- X
- X
- X An example of a Bounding Shape:
- X
- X OBJECT
- X INTERSECTION
- X SPHERE <0.0 0.0 0.0> 2.0 END_SPHERE
- X PLANE <0.0 1.0 0.0> 0.0 END_PLANE
- X PLANE <1.0 0.0 0.0> 0.0 END_PLANE
- X END_INTERSECTION
- X
- X BOUNDED_BY
- X SPHERE <0.0 0.0 0.0> 2.0 END_SPHERE
- X END_BOUND
- X END_OBJECT
- X
- X The best bounding shape is a SPHERE since this shape is highly
- X optimized. Any shape may be used, however.
- X
- XSection 3 - Showing the final pictures
- X
- X When the ray tracer draws the picture on the screen, it does not make
- X good choices for the colour registers. Without knowing all the needed
- X colours ahead of time, only approximate guesses can be made. A post-
- X processor is really needed to view the final image correctly. A post-
- X processor has been provided for the Amiga which scans the picture and
- X chooses the best possible colour registers. It then redisplays the
- X picture. For the Amiga, "DumpToIFF" can optionally save this picture in
- X IFF format. The syntax for the DumpToIFF post-processor is:
- X
- X DumpToIFF filename
- X
- X where the filename is the one given in the -o parameter of the ray
- X tracer. If you didn't specify the -o option, then use:
- X
- X DumpToIFF data.dis
- X
- X If you want to save to an IFF file, then put the name of the IFF file
- X after the name of the data file:
- X
- X DumpToIFF data.dis picture
- X
- X This will create a file called "picture" which contains the IFF image.
- X
- X For the IBM, you will probably want to use the -t option and write the
- X image out in TARGA 24 format. If you have a TARGA or compatible display
- X adapter, you may view the picture in the full 16 million colors (that's
- X why they still cost the big $$ bucks). If you don't, there are several
- X post-processing programs available to convert the TARGA true-color image
- X into a more suitable color-mapped image (such as .GIF). If you have a
- X VGA or MCGA adapter capable of 320x200 by 256 colors, then you may use
- X the -d option which will display the image as it generates using only
- X approximate screen colors. No hardware test is performed, so if you
- X don't have a VGA or MCGA, -> DON'T <- use the -d option!
- X
- X When displaying the image to screen, a HSV conversion method is used
- X (hue, saturation, value). This is a convenient way of translating
- X colors from a "true color" format (16 million) down a "colour mapped"
- X format of something reasonable (like 256), while still approximating the
- X color as closely as the available display hardware permits. As
- X mentioned previously, the tracer has no way of knowing which colors will
- X be finally used in the image, nor can it deal properly with all of the
- X colors which will be generated (up to 16M), so only 4 shades each of 64
- X possible hues are mapped into the palette DAC, as well as black, white,
- X and two grey levels. The advantage a post-processor has in choosing
- X mapped colors is that it can throw away all the unused colors in the
- X palette map, and thereby free up some space for making better gradient
- X shades of the colors that are actually used.
- X
- X There are several available image processing programs that can do this,
- X a public domain one that is very good is PICLAB, by the Stone Soup Group
- X (the folks who brought you FRACTINT). The procedure is to load the
- X TARGA file, then use the MAKEPAL command to generate a 256 color map
- X which is the histogram-weighted average of the most-used colors in the
- X image (You could also PLOAD a palette file from FRACTINT or one you
- X previously had saved using PSAVE). You then MAP the palette onto the
- X image one of two ways:
- X
- X 1) If the DITHER variable is OFF, a nearest-match-color-fit is used,
- X which can sometimes produce unwanted "banding" of colored regions
- X (called false contours).
- X 2) If the DITHER variable is ON, then a standard dither is used to
- X determine final color values. This is much better at blending the
- X color bands, but can produce noise in reflections and make mirrors
- X appear dirty or imperfect.
- X
- X Then you would typically SHOW the image or GSAVE it into GIF format.
- X While the picture is still in the unmapped form (TARGA, etc.) you can
- X perform a variety of advanced image processing transformations and
- X conversions, so save the .TGA or .RAW files you make (in case you ever
- X get a TARGA card, or give them to a friend who has one!).
- X
- X A commercial product that also does a good job of nearest-match-color-
- X fit is the CONVERT utility of The AutoDesk Animator. However, the
- X dither effect is not as good as that of PICLAB. To convert the file in
- X AA's CONVERT, you LOAD TARGA, then in the CONVERT menu, go to the SCALE
- X function and just hit RENDER. Click on the DITHER (lights up with an
- X asterisk when on) if you want it to use it's dithering. CONVERT will
- X scale (if asked to) and then do a histogram of total used colors like
- X PICLAB, but then makes 7 passes on the color map and image to determine
- X shading thresholds of each hue. This nearly eliminates the color
- X banding (false contours) without resorting to dithering. By now you
- X must get the feeling DITHER is a 4-letter word. If you have a low-
- X resolution display, it is. If you have too few colors, however, it can
- X be a saving grace. At resolutions of 640x400 or higher the "spray
- X paint" effect of dithering and anti-aliasing is much less noticeable,
- X and effects a much smoother blending appearance.
- X
- XSection 4 - Handy Hints/Quick Start
- X
- X - To see a quick version of your picture, use -w64 -h80 as command
- X line parameters on the Amiga. For the IBM, try -w80 -h50. This
- X displays the picture in a small rectangle so that you can see how
- X it will look.
- X
- X - Try using the sample default files for different usages - QUICK.DEF
- X shows a fast postage-stamp rendering (80x50, as above) to the
- X screen only, LOCKED.DEF will display the picture with anti-aliasing
- X on (takes forever) with no abort (do this before you go to bed...).
- X The normal default options file TRACE.DEF is read and you can
- X supersede this with another .DEF file by specifying it on the
- X command line, for example:
- X
- X trace -iworld.dat -oworld.out quick.def
- X
- X - When translating light sources, translate the OBJECT, not the
- X QUADRIC surface. The light source uses the center of the object as
- X the origin of the light.
- X
- X - When animating objects with solid textures, the textures must move
- X with the object, i.e. apply the same ROTATE or TRANSLATE functions
- X to the texture as to the object itself.
- X
- X - You can declare constants for most of the data types in the program
- X including floats and vectors. By combining this with INCLUDE
- X files, you can easily separate the parameters for an animation into
- X a separate file.
- X
- X - The amount of ambient light plus diffuse light should be less than
- X or equal to 1.0. The program accepts any value, but may produce
- X strange results.
- X
- X - When using ripples, don't make the ripples too deep or you may get
- X strange results (the dreaded "digital zits"!).
- X
- X - Wood textures usually look better when they are scaled to different
- X values in x, y, and z, and rotated to a different angle.
- X
- X - You can sort of dither a colour by placing a floating point number
- X into the texture record:
- X
- X TEXTURE
- X 0.05
- X END_TEXTURE
- X
- X This adds a small random value to the intensity of the diffuse
- X light on the object. Don't make the number too big or you may get
- X strange results.
- X
- X Better results can be obtained, however, by doing the dithering in
- X a post-processor.
- X
- X
- X - You can compensate for non-square aspect ratios on the monitors by
- X making the RIGHT vector in the VIEWPOINT longer or shorter. A good
- X value for the Amiga is about 1.333. This seems ok for IBM's too at
- X 320x200 resolution. If your spheres and circles aren't round, try
- X varying it.
- X
- X - If you are importing images from other systems, you may find that
- X the shapes are backwards (left-to-right inverted) and no rotation
- X can make them right. All you have to do is negate the terms in the
- X RIGHT vector of the viewpoint to flip the camera left-to-right.
- X
- X - By making the DIRECTION vector in the VIEWPOINT longer, you can
- X achieve the effect of a zoom lens.
- X
- X - When rendering on the Amiga, use a resolution of 319 by 400 to
- X create a full sized HAM picture.
- X
- X
- XSection 5 - Known Bugs
- X There is a bug in the code to use Vector constants. The fix involves
- X re-working the parser quite a bit and I don't want to do that now.
- X
- X
- XSection 6 - Concluding remarks
- X
- X I'm sure that there are bugs in the code somewhere, but I've done my
- X best to remove all the bugs I could find. I also think that the object
- X description language needs to be re-worked. Its current syntax is a bit
- X cumbersome. The system could also use a good graphical interface :-).
- X
- X To that end, a conversion utility is supplied which will take in a
- X Sculpt-Animate 4-D object and map it into DKB's primitive TRIANGLES.
- X For the IBM, we have heard, but cannot confirm, there is a utility
- X around which will convert AUTOCAD .DXF files into Sculpt-4D files. If
- X anybody has it or any info about it, please contact either David Buck or
- X Aaron Collins.
- X
- X The IBM version is also supplied with two stand-alone TARGA-24 utilities
- X which were written by Aaron A. Collins. These are HALFTGA, which will
- X chop a TARGA-24 file in half in both X and Y dimensions for low-
- X resolution systems, and another file called GLUETGA which will paste
- X together several TARGA-24 files (of any resolution) into one. This is
- X principally for concatenating together several partial (interrupted)
- X trace output files into one.
- X
- X I would like to thank Rick Mallett from Carleton University for his help
- X in testing this program, for his comments and suggestions, and for
- X creating the data file for ROMAN.DATA - awesome!
- X
- X I would also like to thank my beta testers for all the help, bug reports,
- X suggestions, comments, and time spent. This version of the ray tracer
- X wouldn't have been possible without them. Thanks guys.
- X
- XEnjoy,
- XDavid Buck
- X
- END_OF_FILE
- if test 65462 -ne `wc -c <'Docs/dkb.doc'`; then
- echo shar: \"'Docs/dkb.doc'\" unpacked with wrong size!
- fi
- # end of 'Docs/dkb.doc'
- fi
- echo shar: End of archive 10 \(of 10\).
- cp /dev/null ark10isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 10 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
- Mail comments to the moderator at <amiga-request@uunet.uu.net>.
- Post requests for sources, and general discussion to comp.sys.amiga.
-